package utils

import (
	"gorm.io/gorm"
	"rabbit_love/src/conf"
	"rabbit_love/src/model"
	"rabbit_love/src/utils"
)

var ClientDB *gorm.DB

func CreateClientDB() {
	ClientDB = utils.InitMysql(conf.MysqlUrl)

	// 初始化数据库
	AutoMigrate()
}

func AutoMigrate() {
	ClientDB.AutoMigrate(&model.UserTable{})

	ClientDB.AutoMigrate(&model.LoverInviteTable{})
	ClientDB.AutoMigrate(&model.LoverRelationTable{})
	ClientDB.AutoMigrate(&model.LoverNickNameTable{})
	ClientDB.AutoMigrate(&model.AnniversaryTable{})

	ClientDB.AutoMigrate(&model.ChatTable{})
	ClientDB.AutoMigrate(&model.DailyTable{})
}
